﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZK.Common;

namespace ZK.CoalYardTransManage.Test
{
    public partial class 地磅测试 : Form
    {

        private WagonBalance.WagonBalance wagonBalance;
        public 地磅测试()
        {
            InitializeComponent();
           
        }
        /// <summary>
        /// 获取数据并赋值
        /// </summary>
        /// <param name="a"></param>
        void aaa(double a) => this.Invoke(new Action(() =>
        {
            this.textBox1.Text = a.ToString();
        }));

        private void button1_Click(object sender, EventArgs e)
        {
            SerialPortConfig config = new SerialPortConfig()
            {
                Name = MyCustomConfig.wagonBalanceConfig.Name,
                PortName = MyCustomConfig.wagonBalanceConfig.PortName,
                BaudRate = MyCustomConfig.wagonBalanceConfig.BaudRate,
                DataBits = MyCustomConfig.wagonBalanceConfig.DataBits
            };
            wagonBalance = new WagonBalance.WagonBalance(config);
            wagonBalance.WeightCallback += aaa;
        }
    }
}
